package by.dezhits.liltweets;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import by.dezhits.liltweets.content.contract.UsersContract;
import by.dezhits.liltweets.images.ImageLoader;
import by.dezhits.liltweets.images.ImageLoader.ConvertOnLoadMode;

public class PageActivity extends Activity {

	private static final String FOLLOWING = "Following: ";
	private static final String FOLLOWERS = "Followers: ";
	private static final String TWEETS = "Tweets: ";
	private static final String DOG = "@";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_page);
		Intent intent = getIntent();
		String id = intent.getStringExtra(getString(R.string.id));
		Uri uri = UsersContract.UsersColumns.CONTENT_URI;
		Cursor cursor = getContentResolver().query(uri, null,
				UsersContract.UsersColumns.ID + "='" + id + "'", null, null);
		cursor.moveToFirst();
		TextView name = (TextView) findViewById(R.id.name);
		TextView screen_name = (TextView) findViewById(R.id.screen_name);
		TextView tweets = (TextView) findViewById(R.id.tweets);
		TextView followers = (TextView) findViewById(R.id.followers);
		TextView following = (TextView) findViewById(R.id.following);
		ImageView ava = (ImageView) findViewById(R.id.mypage_profile_image);
		ImageLoader loader = ImageLoader.getInstance();
		String profileImageURL = cursor.getString(cursor
				.getColumnIndex(UsersContract.UsersColumns.PROFILE_IMAGE_URL));
		loader.bind(ava, profileImageURL,
				ConvertOnLoadMode.NORMAL, false);
		name.setText(cursor.getString(cursor
				.getColumnIndex(UsersContract.UsersColumns.NAME)));
		screen_name.setText(DOG + cursor.getString(cursor
				.getColumnIndex(UsersContract.UsersColumns.SCREEN_NAME)));
		tweets.setText(TWEETS + cursor.getString(cursor
				.getColumnIndex(UsersContract.UsersColumns.STATUSES_COUNT)));
		followers.setText(FOLLOWERS
				+ cursor.getString(cursor
						.getColumnIndex(UsersContract.UsersColumns.FOLLOWERS_COUNT)));
		following.setText(FOLLOWING
				+ cursor.getString(cursor
						.getColumnIndex(UsersContract.UsersColumns.FRIENDS_COUNT)));
	}

	
}
